<template>
  <div id="homeBar">
    <!-- 移动端顶部 -->
    <div v-if="isShowMBar && $route.path !== '/search'" class="mBar">
      <div class="mBar_left2" @click="goBack"></div>
      <div class="mBar_center">{{ mBarTitle }}</div>
      <div
        class="mBar_right"
        @click="gotoTransferHistory"
        v-if="$route.path === '/personalCurrentlyOwned'"
      >
        转赠记录
      </div>
      <div
        class="mBar_right"
        @click="gotoSyntheticHistory"
        v-if="$route.path === '/syntheticList'"
      >
        合成记录
      </div>
    </div>
    <div v-if="isShowMBar && $route.path !== '/search'" class="mBrace"></div>

    <!-- pc端顶部 -->
    <div class="bar">
      <div class="wrapper">
        <div class="bar_nav">
          <div class="bar_logo">
            <img
              class="logoImg"
              src="@/assets/images/pc_black/home/homebar_logo.png"
            />
          </div>

          <div class="bar_nav_box" v-show="!isShowSearch">
            <el-tabs
              v-model="activeName"
              @tab-click="changeNav"
              :stretch="true"
            >
              <el-tab-pane label="首页" name="home">首页</el-tab-pane>
              <el-tab-pane label="商城" name="mail">商城</el-tab-pane>
              <el-tab-pane label="流转" name="circulation">流转</el-tab-pane>
              <!-- <el-tab-pane label="交易" name="trade">交易</el-tab-pane> -->
              <el-tab-pane label="合成" name="compose">合成</el-tab-pane>
              <!-- <el-tab-pane label="关于我们" name="about">关于我们</el-tab-pane>
              <el-tab-pane label="常见问题" name="help">常见问题</el-tab-pane> -->
              <el-tab-pane name="notice" v-if="isLogin && noticeNum > 0">
                <el-badge slot="label" is-dot class="noticeDot">公告</el-badge>
              </el-tab-pane>
              <el-tab-pane label="公告" name="notice" v-else>公告</el-tab-pane>
              <el-tab-pane label="APP" name="app" v-if="isApp !== true"
                >APP</el-tab-pane
              >
              <el-tab-pane label="邀请好友" name="invite">
                邀请好友
              </el-tab-pane>
            </el-tabs>

            <img
              class="hot"
              src="@/assets/images/pc_black/home/inviteHot.png"
            />
          </div>

          <div class="bar_more" id="fade_bar_more" v-show="!isShowSearch">
            <div class="more_click" @click="changeMore">
              <span>更多</span>
              <i class="el-icon-arrow-down el-icon--right"></i>
            </div>

            <transition name="fade">
              <div class="more_dd" v-if="isShowMore">
                <ul>
                  <li @click="gotoHelp">常见问题</li>
                  <li @click="gotoAbout">关于我们</li>
                  <li @click="gotoHelpPage">流转帮助</li>
                </ul>
              </div>
            </transition>
          </div>
        </div>

        <div class="bar_search" id="fade_bar_search">
          <img
            class="start"
            src="@/assets/images/pc_black/home/search.png"
            v-if="!isShowSearch"
          />
          <img
            class="end"
            v-else
            @click.stop="search"
            src="@/assets/images/pc_black/search/search.png"
          />
          <img
            v-if="isShowSearch"
            class="end_close"
            @click.stop="clearSearch"
            src="@/assets/images/pc_black/search/close.png"
          />
          <input
            ref="searchInput"
            :class="!isShowSearch ? 'search_input' : 'search_input_search'"
            placeholder="搜索数字产品"
            v-model.trim="searchValue"
            @keyup.enter="search"
            @focus="openSearch"
            @blur="searchBlur"
            @input="searchInputing"
          />
          <!-- 搜索内容框 -->
          <transition name="searchfade">
            <div class="bar_search_content" v-if="isShowSearch">
              <!-- 历史记录（搜索内容为空时显示） -->
              <div class="search_history_content">
                <div class="search_history" v-if="searchValue === ''">
                  <div class="history_title">
                    <span class="title_font">搜索历史</span>
                    <img
                      @click="openHistoryDialog"
                      class="title_img"
                      src="@/assets/images/mobile_black/home/clear_history.png"
                    />
                  </div>

                  <div class="history_content">
                    <div
                      class="content_item"
                      v-for="(item, index) in historyData"
                      :key="index"
                      @click.stop="gotoItem(item)"
                    >
                      {{ textSub(item) }}
                    </div>
                  </div>
                </div>
              </div>

              <!-- 联想提示内容（正在搜索且搜索内容不为空时显示） -->
              <div
                class="search_tip"
                v-if="isShowSearchTip && searchValue !== ''"
              >
                <ul>
                  <li
                    v-for="(item, index) in associateFilterData"
                    :key="index"
                    v-html="mapText(item, searchValue)"
                    @click.stop="searchByTip(index, item)"
                  ></li>
                </ul>
              </div>
            </div>
          </transition>

          <el-button
            v-if="!isLogin"
            class="bar_login"
            @click.stop="openLoginDialog"
            >登录</el-button
          >
          <!-- 头像下拉框 -->
          <div v-else class="bar_userInfo" id="fade_bar_dd">
            <div class="bar_click" @click="changeDD">
              <img
                class="bar_avatar"
                :src="
                  userInfo.avatar
                    ? userInfo.avatar
                    : require('@/assets/images/mobile_black/center/avatar_default.png')
                "
              />
              <i class="el-icon-arrow-down el-icon--right"></i>
            </div>

            <transition name="fade">
              <div class="bar_dd" v-if="isShowDD">
                <ul>
                  <li @click="gotoPersonalCenter">个人中心</li>
                  <li class="dd_auth" @click="gotoAuth">
                    <span>实名认证</span>
                    <span>{{
                      userInfo.is_auth === 1 ? "已认证" : "未认证"
                    }}</span>
                  </li>
                  <li @click="exitLogin">退出登录</li>
                </ul>
              </div>
            </transition>
          </div>
        </div>
      </div>
    </div>
    <div class="pcBrace"></div>

    <!-- pc登录 -->
    <el-dialog
      class="loginDialog"
      :visible="isShowLogin"
      width="30%"
      center
      :before-close="closeLoginDialog"
      :show-close="false"
      :close-on-click-modal="false"
    >
      <div class="dialog_title">
        <img
          @click="closeLoginDialog"
          src="@/assets/images/pc_black/auth/close.png"
        />
      </div>

      <div class="dialog_center">
        <div class="form_title">
          <span>登录账户</span>
          <span>手机号码登录</span>
        </div>

        <div class="form_content">
          <input
            type="tel"
            v-model="formData.phone"
            placeholder="请输入手机号"
            maxlength="11"
            @input="phoneInputing"
          />
          <input
            type="text"
            v-model="formData.code"
            placeholder="请输入验证码"
            maxlength="6"
            @input="codeInputing"
          />
          <button
            class="getCodeBtn"
            @click.stop="getCode"
            :disabled="isCodeBtnDisabled"
            :class="{ opacityHalf: isCodeBtnDisabled }"
          >
            {{ codeBtnContent }}
          </button>

          <transition name="fade1">
            <div class="form_captch" v-show="isShowCap">
              <NoCaptcha
                @slideCallback="finishSlide"
                @hiddenCap="hiddenCap"
                :reload="reload"
                :phone="formData.phone"
              />
            </div>
          </transition>

          <div class="form_btn">
            <button
              v-if="isLoginBtnDisabled"
              class="btn_grey"
              :disabled="isLoginBtnDisabled"
            >
              登录账户
            </button>
            <button
              v-else
              class="btn_color"
              :disabled="isLoginBtnDisabled"
              @click="userLogin"
            >
              登录账户
            </button>
          </div>
        </div>

        <div class="form_agree">
          <div class="login_agree">
            <img
              @click="changeNextLogin"
              v-if="isNextLogin"
              src="@/assets/images/pc_black/auth/select_yes.png"
            />
            <!-- <img
              @click="changeNextLogin"
              v-else
              src="@/assets/images/pc_black/auth/select_not.png"
            />
            <span @click="changeNextLogin">下次自动登录</span> -->
          </div>

          <div class="privacy_agree">
            <img
              @click="changeAgree"
              v-if="isAgree"
              src="@/assets/images/pc_black/auth/select_yes.png"
            />
            <img
              @click="changeAgree"
              v-else
              src="@/assets/images/pc_black/auth/select_not.png"
            />
            <div>
              未注册手机验证过后自动登录，注册即表示同意<span
                class="privacySpan"
                @click="gotoAgreement"
                >《用户协议》</span
              >和<span class="privacySpan" @click="gotoPrivacy"
                >《隐私政策》</span
              >
            </div>
          </div>
        </div>

        <div class="other_login">
          <div class="wx_line">
            <i></i>
            <span>微信扫码登录</span>
            <i></i>
          </div>

          <div class="wx_img">
            <img
              @click.stop="wxLogin"
              src="@/assets/images/pc_black/auth/wx.png"
            />
          </div>
        </div>
      </div>
    </el-dialog>

    <!-- 微信二维码弹窗 -->
    <el-dialog
      class="wxDialog"
      title="扫描二维码并关注公众号进行登录"
      :visible.sync="isShowWxDialog"
      width="25%"
      :before-close="closeWxDialog"
      center
    >
      <img class="ewm" :src="ewmUrl" />
    </el-dialog>

    <!-- 绑定手机号弹窗 -->
    <el-dialog
      class="bundleDialog"
      :visible="isShowBundlePhoneDialog"
      width="30%"
      :before-close="closeBundlePhoneDialog"
      :show-close="false"
      center
      :close-on-click-modal="false"
    >
      <div class="dialog_title">
        <img
          @click="closeBundlePhoneDialog"
          src="@/assets/images/pc_black/auth/close.png"
        />
      </div>
      <div class="dialog_center">
        <div class="form_title">
          <span>关联您的手机号码</span>
          <span>微信登录</span>
        </div>

        <div class="form_content">
          <input
            type="tel"
            v-model="bundleFormData.phone"
            placeholder="请输入手机号"
            maxlength="11"
            @input="bundlePhoneInputing"
          />
          <input
            type="text"
            v-model="bundleFormData.code"
            placeholder="请输入验证码"
            maxlength="6"
            @input="bundleCodeInputing"
          />
          <button
            class="getCodeBtn"
            @click.stop="getBundleCode"
            :disabled="cantCodeBtn"
            :class="{ opacityHalf: cantCodeBtn }"
          >
            {{ bundleBtnContent }}
          </button>

          <!-- <transition name="fade2">
            <div class="form_captch" v-show="isShowCap">
              <NoCaptcha
                @slideCallback="finishSlide"
                @hiddenCap="hiddenCap"
                @resetBundle="resetBundle"
                :reload="reload"
                :phone="bundleFormData.phone"
                :isBundle="isBundle"
              />
            </div>
          </transition> -->

          <div class="form_btn" :class="{ form_btn_margin: isShowCap }">
            <button v-if="cantSubmit" class="btn_grey" :disabled="cantSubmit">
              确认关联
            </button>
            <button
              v-else
              class="btn_color"
              :disabled="cantSubmit"
              @click="bundleLogin"
            >
              确认关联
            </button>
          </div>
        </div>
      </div>
    </el-dialog>

    <!-- 清空历史记录弹窗 -->
    <el-dialog
      class="historyDialog"
      :visible="isShowHistoryDialog"
      width="30%"
      :before-close="closeHistoryDialog"
      :show-close="false"
      center
      :close-on-click-modal="false"
    >
      <div class="dialog_title">
        <span>清空历史记录</span>
        <img
          @click="closeHistoryDialog"
          src="@/assets/images/pc_black/auth/close.png"
        />
      </div>

      <div class="dialog_center">清空记录后将无法回复，确定删除吗？</div>

      <div class="dialog_bottom">
        <el-button @click="closeHistoryDialog">取消</el-button>
        <el-button @click="clearHistory">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
// lodash
import _ from "lodash";
// store
import { mapMutations, mapState, mapActions } from "vuex";
// 异步
import { clearCookies, setCookie } from "@/utils/cookie";
import { iscode, isWeixin, getWidth } from "@/utils";
import {
  userLoginApi,
  sendVerificationCodeApi,
  sendRegisterVerifyCodeApi,
  bindPhoneApi,
  wxQrcodeApi,
  checkWxScanLoginApi,
  associateSearchApi,
  noticeInfoApi,
  verifyOneBuyCodeApi,
} from "@/api";

// vuelidate
import { required, minLength } from "vuelidate/lib/validators";
// components
import NoCaptcha from "@/components/NoCaptch";

export default {
  name: "HomeBar",
  components: { NoCaptcha },
  data() {
    return {
      formData: {
        phone: "",
        code: "",
      },
      bundleFormData: {
        phone: "",
        code: "",
      },
      // 搜索历史记录
      historyData: [],
      // 搜索提示结果
      associateFilterData: [],
      // 是否显示二维码
      isShowWxDialog: false,
      // 是否显示绑定手机号的弹窗
      isShowBundlePhoneDialog: false,
      // 是否展示登录弹窗
      isShowLogin: false,
      // 是否展示移动端头部
      isShowMBar: false,
      // 搜索的内容
      searchValue: "",
      // 当前选择
      activeName: "home",
      // 验证码按钮是否禁止
      isCodeBtnDisabled: true,
      // 验证码计时数
      codeTimeingNum: 60,
      // 按钮是否通过点击启动
      byClick: false,
      // 登录按钮是否禁止
      isLoginBtnDisabled: true,
      // 是否同意下次登录
      isNextLogin: false,
      // 是否同意政策
      isAgree: false,
      // 绑定验证码按钮睡否禁止
      cantCodeBtn: true,
      // 绑定弹窗的确认按钮是否禁止
      cantSubmit: true,
      // 绑定验证码计时
      // 验证码计时数
      codeTimeingNum2: 60,
      // 按钮是否通过点击启动
      byClick2: false,
      // 二维码地址
      ewmUrl: "",
      // 二维码过期倒计时
      wxTimerNum: 60,
      // 二维码计时器
      wxTimer: null,
      // check参数
      scene_id: "",
      // openid
      openid: "",
      // 是否登录
      isLogin: false,
      // 是否显示下拉框
      isShowDD: false,
      // 是否显示搜索框
      isShowSearch: false,
      // 是否显示搜索tip
      isShowSearchTip: false,
      // 是否显示确认删除历史记录弹窗
      isShowHistoryDialog: false,
      isWX: false,
      // 邀请码
      inviteCode: null,
      // 一元购
      onebuy_code: null,
      // 是否重置验证
      reload: false,
      // 是否显示重置验证
      isShowCap: false,
      // 验证附带信息
      secret: "",
      // 是否是绑定验证码
      isBundle: false,
      noticeNum: 0,
      isApp: JSON.parse(localStorage.getItem("isApp")),
      // 是否展示更多下拉框
      isShowMore: false,
    };
  },
  // vuelidate验证表单
  validations: {
    formData: {
      phone: {
        required,
        minLength: minLength(11),
      },
      code: {
        required,
        minLength: minLength(6),
      },
    },
    bundleFormData: {
      phone: {
        required,
        minLength: minLength(11),
      },
      code: {
        required,
        minLength: minLength(6),
      },
    },
  },
  computed: {
    // vuex
    ...mapState(["userInfo"]),

    // mBar的title显示
    mBarTitle() {
      let title = this.$route.meta.title;
      if (this.$route.path === "/") {
        title = "METAUP——专业的数字藏品发行平台";
      }
      return title;
    },
    // 验证码按钮显示
    codeBtnContent() {
      if (this.isCodeBtnDisabled && this.byClick) {
        return "剩余" + this.codeTimeingNum + "S";
      } else {
        return "获取验证码";
      }
    },
    // 绑定验证码按钮显示
    bundleBtnContent() {
      if (this.cantCodeBtn && this.byClick2) {
        return "剩余" + this.codeTimeingNum2 + "S";
      } else {
        return "获取验证码";
      }
    },
  },
  watch: {
    $route(val) {
      if (val.path !== "/search") {
        this.searchValue = "";
      }

      // pc的tab栏
      switch (val.path) {
        case "/mail/albumDetail":
        case "/mail/albumItem":
        case "/mail/productDetail":
        case "/mail/productItem":
          this.activeName = "mail";
          break;
        case "pay":
          break;
        case "/aboutUs":
          this.activeName = "about";
          break;
        case "/helpCenter":
          this.activeName = "help";
          break;
        case "/syntheticList":
        case "/syntheticHistory":
        case "/syntheticAction":
          this.activeName = "compose";
          break;
        case "/noticeItem":
        case "/noticeList":
          this.activeName = "notice";
          // 如果没有，就给一个0
          let noticeNum = localStorage.getItem("noticeNum");
          if (!noticeNum) {
            localStorage.setItem("noticeNum", JSON.stringify(0));
          } else {
            if (this.isLogin) {
              // 如果有，则算一下新的数量与上一次数量的差
              this.noticeNum = this.userInfo.notice_num - noticeNum;
            }
          }
          break;
        case "/inviteCode":
          this.activeName = "invite";
          break;
        case "/appDownload":
          this.activeName = "app";
          break;
        case "/":
          this.activeName = "home";
        default:
          break;
      }

      // 移动端头部是否显示
      let routeArr = [
        "/personalCurrentlyOwned",
        "/unpaid",
        "/cancelled",
        "/personalFavorite",
        "/personalCollection",
        "/resetPassword",
        "/setPassword",
        "/authentication",
        "/aboutUs",
        "/helpCenter",
        "/blockchain",
        "/personalModify",
        "/personalNicknameModify",
        "/personalDescriptionModify",
        "/mail/inviteShare",
        "/mail/inviteCode",
        "/mail/inviteRecord",
        "/discount",
        "/transferHistory",
        "/noticeList",
        "/noticeItem",
        "/syntheticList",
        "/syntheticHistory",
        "/appDownload",
        "/address",
        "/addressPhone",
      ];
      if (routeArr.indexOf(this.$route.path) === -1) {
        this.isShowMBar = false;
      } else {
        this.isShowMBar = true;
      }
    },

    searchValue(val) {
      if (val.trim() === "") {
        let historyData = JSON.parse(localStorage.getItem("searchHistory"));
        if (historyData && historyData.length > 0) {
          this.historyData = historyData.filter((item, index) => index < 40);
        }
      }
    },
  },
  mounted() {
    // 移动端头部是否显示
    let routeArr = [
      "/personalCurrentlyOwned",
      "/unpaid",
      "/cancelled",
      "/personalFavorite",
      "/personalCollection",
      "/resetPassword",
      "/setPassword",
      "/authentication",
      "/aboutUs",
      "/helpCenter",
      "/blockchain",
      "/personalModify",
      "/personalNicknameModify",
      "/personalDescriptionModify",
      "/mail/inviteShare",
      "/mail/inviteCode",
      "/mail/inviteRecord",
      "/discount",
      "/transferHistory",
      "/noticeList",
      "/noticeItem",
      "/syntheticList",
      "/syntheticHistory",
      "/appDownload",
      "/ruleDesc",
      "/address",
      "/addressPhone",
    ];
    if (routeArr.indexOf(this.$route.path) === -1) {
      this.isShowMBar = false;
    } else {
      this.isShowMBar = true;
    }
    // 是否是微信
    if (isWeixin()) {
      this.isWX = true;
    } else {
      this.isWX = false;
    }

    // 刷新之后,pc的tab栏
    window.addEventListener("load", () => {
      switch (this.$route.path) {
        case "/mail/albumDetail":
        case "/mail/albumItem":
        case "/mail/productDetail":
        case "/mail/productItem":
          this.activeName = "mail";
          break;
        case "pay":
          break;
        case "/aboutUs":
          this.activeName = "about";
          break;
        case "/helpCenter":
          this.activeName = "help";
          break;
        case "/syntheticList":
        case "/syntheticHistory":
        case "/syntheticAction":
          this.activeName = "compose";
          break;
        case "/noticeItem":
        case "/noticeList":
          this.activeName = "notice";
          break;
        case "/mail/inviteCode":
          this.activeName = "invite";
          break;
        case "/appDownload":
          this.activeName = "app";
          break;
        default:
          break;
      }

      // 如果没有，就给一个0
      let noticeNum = localStorage.getItem("noticeNum");
      if (!noticeNum) {
        localStorage.setItem("noticeNum", JSON.stringify(0));
      } else {
        if (this.isLogin) {
          // 如果有，则算一下新的数量与上一次数量的差
          this.noticeNum = this.userInfo.notice_num - noticeNum;
        }
      }
    });

    // 是否登录
    let isLogin = JSON.parse(localStorage.getItem("isLogin"));
    if (isLogin === true) {
      this.isLogin = true;
      this.$nextTick(() => {
        this.getUserInfo();
      });

      // 如果没有，就给一个0
      let noticeNum = localStorage.getItem("noticeNum");
      if (!noticeNum) {
        localStorage.setItem("noticeNum", JSON.stringify(0));
      } else {
        // 如果有，则算一下新的数量与上一次数量的差
        this.noticeNum = this.userInfo.notice_num - noticeNum;
      }

      // 如果商品id参数存在，则跳转到对应页面
      if (this.$route.query.id && this.$route.path == "/") {
        this.$router.push({
          path: "/mail/productDetail",
          query: {
            id: this.$route.query.id - 0,
          },
        });
      }
    } else {
      this.isLogin = false;
      if (
        this.$route.path === "/" &&
        this.$route.query.inviteCode &&
        getWidth() > 768
      ) {
        this.inviteCode = this.$route.query.inviteCode;
        this.isShowLogin = true;
      } else if (
        this.$route.path === "/" &&
        this.$route.query.onebuy_code &&
        getWidth() > 768
      ) {
        this.onebuy_code = this.$route.query.onebuy_code;
      }

      if (getWidth() > 768) {
        if (
          this.$route.query.onebuy_code &&
          this.$route.query.onebuy_code != -1
        ) {
          this.isShowLogin = true;
          setTimeout(() => {
            this.verifyOneBuyCode();
          }, 100);
        }
      }
    }

    let historyData = JSON.parse(localStorage.getItem("searchHistory"));
    if (historyData && historyData.length > 0) {
      this.historyData = historyData.filter((item, index) => index < 40);
    }

    // 点击外侧关闭dd
    document.addEventListener("mouseup", (e) => {
      //获取弹窗对象
      const userCon = document.getElementById("fade_bar_dd");
      const userCon2 = document.getElementById("fade_bar_search");
      const userCon3 = document.getElementById("fade_bar_more");

      //判断弹窗对象中是否包含点击对象
      if (userCon && !userCon.contains(e.target)) {
        this.isShowDD = false;
      }

      if (userCon2 && !userCon2.contains(e.target)) {
        this.isShowSearch = false;
      }

      if (userCon3 && !userCon3.contains(e.target)) {
        this.isShowMore = false;
      }
    });
  },
  methods: {
    // store方法：打开登录/认证滑框
    ...mapMutations(["clearUserInfo"]),
    ...mapActions(["getUserInfo"]),

    // ----- 异步相关 -----
    // 检测一元购邀请码是否有效
    async verifyOneBuyCode() {
      let res = await verifyOneBuyCodeApi({
        onebuy_code: this.onebuy_code ?? "",
      });
      if (iscode(res)) {
      }
    },

    // 登录（登录成功则跳转到个人中心）
    async userLogin() {
      let res = await userLoginApi({
        phone: this.formData.phone,
        verify_code: this.formData.code,
        invite_code: this.inviteCode ?? "",
        onebuy_code: this.onebuy_code ?? "",
        secret: this.secret,
      });
      if (iscode(res)) {
        this.noticeInfo();
        window.localStorage.setItem("isLogin", true);
        window.localStorage.setItem("pcFirstLogin", true);
        this.isLogin = true;
        setCookie("token", res.result.token, 7);
        window.localStorage.setItem("token", JSON.stringify(res.result.token));
        this.$message({
          message: "登录成功",
          iconClass: "mySuccessIcon",
          customClass: "mySuccess",
        });
        this.getUserInfo();
        this.closeLoginDialog();
        // 如果商品id参数存在，则跳转到对应页面
        if (this.$route.query.id) {
          this.$router.push({
            path: "/mail/productDetail",
            query: {
              id: this.$route.query.id - 0,
            },
          });
        }
      } else {
        this.formData.code = "";
        this.reload = true; // 需要重置滑块
      }
    },
    // 发送短信验证码（绑定手机号）
    async getBundleCode() {
      let res = await sendRegisterVerifyCodeApi({
        phone: this.bundleFormData.phone,
      });
      if (iscode(res)) {
        if (res.code === 200005) {
          return;
        }
        this.cantCodeBtn = true;
        this.byClick2 = true;
        this.$message({
          message: res.message,
          iconClass: "mySuccessIcon",
          customClass: "mySuccess",
        });
        // 验证码计时
        let codeTimer = setInterval(() => {
          this.codeTimeingNum2 = this.codeTimeingNum2 - 1;
          if (this.codeTimeingNum2 === 0) {
            this.cantCodeBtn = false;
            this.byClick2 = false;
            clearInterval(codeTimer);
            this.codeTimeingNum2 = 60;
          }
        }, 1000);
      }
    },
    // 微信定时监测用户是否扫码
    async checkWxScanLogin() {
      let res = await checkWxScanLoginApi({ scene_id: this.scene_id });
      if (iscode(res)) {
        if (res.code === 0) {
          // 正常check：
          // 1.result为null代表没扫码
          // 2.result不为null，且参数is_first为0代表扫码成功，且账号存在可以直接登录
          // 3.result不为null，且参数is_first为1代表扫码成功，但是第一次登录，需要绑定手机号码才可登录
          if (res.result && res.result.is_first_login === 0) {
            this.openid = res.result.openid;
            // 以前登录过（重置定时器的数据，并且关闭所有弹窗，跳过通过正常登录流程直接登录成功）
            clearInterval(this.wxTimer);
            this.wxTimerNum = 60;
            this.closeWxDialog();
            this.closeLoginDialog();
            window.localStorage.setItem("isLogin", true);
            this.isLogin = true;
            setCookie("token", res.result.token, 7);
            window.localStorage.setItem(
              "token",
              JSON.stringify(res.result.token)
            );
            this.getUserInfo();
            this.$message({
              message: "登录成功",
              iconClass: "mySuccessIcon",
              customClass: "mySuccess",
            });

            // 如果商品id参数存在，则跳转到对应页面
            if (this.$route.query.id) {
              this.$router.push({
                path: "/mail/productDetail",
                query: {
                  id: this.$route.query.id - 0,
                },
              });
            }
          } else if (res.result && res.result.is_first_login === 1) {
            this.openid = res.result.openid;
            // 第一次登录，需要绑定手机号（重置定时器数据，开始绑定手机号码弹窗，如果不绑定则关闭所有弹窗，登录不成功。如果绑定成功，则关闭所有弹窗，跳过通过正常登录流程直接登录成功）
            clearInterval(this.wxTimer);
            this.wxTimerNum = 60;
            this.closeWxDialog();
            this.isShowBundlePhoneDialog = true; // 开启绑定手机号弹窗
          }
        }
      }
    },
    // 微信扫码登录
    async wxLogin() {
      if (!this.isAgree) {
        this.$message({
          message: "请勾选并同意协议",
          iconClass: "myWarningIcon",
          customClass: "myWarning",
        });
        return;
      }
      let res = await wxQrcodeApi();
      if (iscode(res)) {
        this.ewmUrl =
          "https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" +
          res.result.ticket;
        this.scene_id = res.result.scene_id;
      }
      this.isShowWxDialog = true;
      this.wxTimer = setInterval(() => {
        if (this.wxTimerNum <= 0) {
          clearInterval(this.wxTimer);
          this.wxTimerNum = 60;
          this.closeWxDialog();
          this.$message({
            message: "扫码已超时，请重试",
            iconClass: "myWarningIcon",
            customClass: "myWarning",
          });
          return;
        }
        this.checkWxScanLogin();
        this.wxTimerNum--;
      }, 1000);
    },
    // 微信扫码登录第一次绑定手机确定登录
    async bundleLogin() {
      let res = await bindPhoneApi({
        openid: this.openid,
        nickname: "",
        headimgurl: "",
        phone: this.bundleFormData.phone,
        code: this.bundleFormData.code,
        invite_code: this.inviteCode ?? "",
        onebuy_code: this.onebuy_code ?? "",
        secret: this.secret,
      });
      if (iscode(res)) {
        this.closeBundlePhoneDialog();
        this.closeLoginDialog();
        window.localStorage.setItem("isLogin", true);
        setCookie("token", res.result.token, 7);
        window.localStorage.setItem("token", JSON.stringify(res.result.token));
        this.getUserInfo();
        this.$message({
          message: "登录成功",
          iconClass: "mySuccessIcon",
          customClass: "mySuccess",
        });
        this.isLogin = true;
        this.initBundleForm();
        // 如果商品id参数存在，则跳转到对应页面
        if (this.$route.query.id) {
          this.$router.push({
            path: "/mail/productDetail",
            query: {
              id: this.$route.query.id - 0,
            },
          });
        }
      }
    },
    // 搜索联想
    associateSearch: _.debounce(async function() {
      this.isShowSearchTip = true;
      let res = await associateSearchApi({
        keywords: this.searchValue.trim(),
      });
      if (iscode(res)) {
        if (res.result !== null && res.result.list) {
          this.associateData = res.result.list;
          this.associateFilterData = Object.assign([], res.result.list);
          this.associateFilterData.forEach((item, index) => {
            if (item.length > 30) {
              this.associateFilterData.splice(
                index,
                1,
                item.slice(0, 30) + "..."
              );
            }
          });
        }
      }
    }, 400),
    // 请求公告
    async noticeInfo() {
      let res = await noticeInfoApi({
        page: 1,
        pagesize: 1,
      });
      if (iscode(res)) {
        if (res.result.count > 0) {
          this.$store.commit("openHomeNotice");
        }
      }
    },

    // ----- 功能性方法 -----
    // 重置版定验证码记号
    resetBundle() {
      this.isBundle = false;
    },
    // 发送短信验证码
    getCode() {
      this.showCap();
    },
    // 发送绑定验证吗
    getCodeBun() {
      this.isBundle = true;
      this.showCap();
      // 验证码计时
      this.cantCodeBtn = true;
      this.byClick2 = true;
      let codeTimer = setInterval(() => {
        this.codeTimeingNum2 = this.codeTimeingNum2 - 1;
        if (this.codeTimeingNum2 === 0) {
          this.cantCodeBtn = false;
          this.byClick2 = false;
          clearInterval(codeTimer);
          this.codeTimeingNum2 = 60;
          this.reload = true; // 重置验证
          this.hiddenCap();
        }
      }, 1000);
    },
    // show ic
    showCap() {
      this.isShowCap = true;
    },
    // hidden ic
    hiddenCap() {
      this.isShowCap = false;
    },
    // 验证成功
    finishSlide(secret) {
      this.secret = secret;
      // 验证码计时
      this.isCodeBtnDisabled = true;
      this.byClick = true;
      let codeTimer = setInterval(() => {
        this.codeTimeingNum = this.codeTimeingNum - 1;
        if (this.codeTimeingNum === 0) {
          this.reload = true; // 重置验证
          this.hiddenCap();
          this.isCodeBtnDisabled = false;
          this.byClick = false;
          clearInterval(codeTimer);
          this.codeTimeingNum = 60;
        }
      }, 1000);
    },
    // 打开确认清空历史记录弹窗
    openHistoryDialog() {
      this.isShowHistoryDialog = true;
    },
    // 关闭确认清空历史记录弹窗
    closeHistoryDialog() {
      this.isShowHistoryDialog = false;
    },
    // 通过点击历史记录搜索
    gotoItem(item) {
      this.searchValue = item;
      this.search();
      this.closeSearch();
    },
    // 清空历史记录
    clearHistory() {
      this.closeHistoryDialog();
      this.$message({
        message: "已清空",
        iconClass: "mySuccessIcon",
        customClass: "mySuccess",
      });
      this.historyData = [];
      localStorage.removeItem("searchHistory");
    },
    // 搜索框正在输入
    searchInputing() {
      if (this.searchValue !== "") {
        this.associateSearch();
        this.isShowSearchTip = true;
      }
    },
    // 搜索框失去焦点
    searchBlur() {
      // this.isShowSearchTip = false;
    },
    // 超出省略
    textSub(text) {
      let res = text;
      if (text && text.length > 10) {
        res = text.substring(0, 10) + "...";
      }
      return res;
    },
    // 通过点击tip搜索
    searchByTip(index, item) {
      this.searchValue = this.associateData[index];
      this.search();
    },
    // 搜索关键字高亮
    mapText(text, keyword) {
      // (text是原数据，keyword是搜索的关键字)
      var reg = /<script[^>]*>(.|\n)*<\/script>/gi; //去掉script标签
      text = text.replace(reg, "");
      var num = -1;
      var kwReg = new RegExp(keyword, "gi"); //匹配传入的搜索值不区分大小写 i表示不区分大小写，g表示全局搜索
      var htmlReg = new RegExp("<.*?>", "ig"); //匹配html元素
      var aHtml = text.match(htmlReg); //存放html元素的数组
      var arr = text.match(kwReg);
      var a = -1;
      text = text.replace(htmlReg, "{~}"); //替换html标签
      text = text.replace(kwReg, function() {
        a++;
        return "<span style='color: #00FFB0'>" + arr[a] + "</span>";
      }); //替换key
      text = text.replace(/{~}/g, function() {
        //恢复html标签
        num++;
        return aHtml[num];
      });
      return text;
    },
    // 清空搜索框
    clearSearch() {
      // this.searchValue = "";
      this.closeSearch();
    },
    // 打开搜索框
    openSearch() {
      this.isShowSearch = true;
      if (this.searchValue !== "") {
        this.associateSearch();
      }
    },
    // 关闭下拉框
    closeSearch() {
      this.isShowSearch = false;
    },
    // 切换下拉框显示
    changeDD() {
      this.isShowDD = !this.isShowDD;
      this.closeSearch();
    },
    // 关闭下拉框
    closeDD() {
      this.isShowDD = false;
    },
    // 初始化表单
    initForm() {
      this.formData = {
        phone: "",
        code: "",
      };
      this.isCodeBtnDisabled = true;
      this.isAgree = false;
      // 重置验证
      this.isBundle = false;
      this.hiddenCap();
      this.reload = true;
    },
    initBundleForm() {
      this.bundleFormData = {
        phone: "",
        code: "",
      };
      this.cantCodeBtn = true;
      // 重置验证
      this.isBundle = false;
      this.hiddenCap();
      this.reload = true;
    },
    // 手机输入框输入时，正则限制只能输入数字
    phoneInputing() {
      this.$nextTick(() => {
        this.formData.phone = this.formData.phone.replace(/[^\d]/g, "");
      });
      if (this.codeTimeingNum === 60) {
        if (!this.$v.formData.phone.$invalid) {
          this.isCodeBtnDisabled = false;
        } else {
          this.isCodeBtnDisabled = true;
        }
      }
      if (!this.$v.formData.$invalid && this.isAgree) {
        this.isLoginBtnDisabled = false;
      } else {
        this.isLoginBtnDisabled = true;
      }
    },
    codeInputing() {
      this.$nextTick(() => {
        this.formData.code = this.formData.code.replace(/[^\d]/g, "");
      });

      if (!this.$v.formData.$invalid && this.isAgree) {
        this.isLoginBtnDisabled = false;
      } else {
        this.isLoginBtnDisabled = true;
      }
    },
    // 手机输入框输入时，正则限制只能输入数字
    bundlePhoneInputing() {
      this.$nextTick(() => {
        this.bundleFormData.phone = this.bundleFormData.phone.replace(
          /[^\d]/g,
          ""
        );
      });
      if (this.codeTimeingNum2 === 60) {
        if (!this.$v.bundleFormData.phone.$invalid) {
          this.cantCodeBtn = false;
        } else {
          this.cantCodeBtn = true;
        }
      }
      if (!this.$v.bundleFormData.$invalid) {
        this.cantSubmit = false;
      } else {
        this.cantSubmit = true;
      }
    },
    bundleCodeInputing() {
      this.$nextTick(() => {
        this.bundleFormData.code = this.bundleFormData.code.replace(
          /[^\d]/g,
          ""
        );
      });

      if (!this.$v.bundleFormData.$invalid) {
        this.cantSubmit = false;
      } else {
        this.cantSubmit = true;
      }
    },
    // 切换是否同意协议
    changeAgree() {
      this.isAgree = !this.isAgree;
      if (!this.$v.formData.$invalid && this.isAgree) {
        this.isLoginBtnDisabled = false;
      } else {
        this.isLoginBtnDisabled = true;
      }
    },
    // 切换是否下次登录
    changeNextLogin() {
      this.isNextLogin = !this.isNextLogin;
    },
    // 打开登录注册弹窗
    openLoginDialog() {
      this.isShowLogin = true;
      this.closeSearch();
      this.reload = false;
    },
    // 关闭登录注册弹窗
    closeLoginDialog() {
      this.isShowLogin = false;
      this.initForm();
      this.reload = true; // 重置验证
      this.hiddenCap();
    },
    // 关闭微信弹窗
    closeWxDialog() {
      this.isShowWxDialog = false;
      clearInterval(this.wxTimer);
      this.wxTimerNum = 60;
    },
    // 关闭绑定手机号弹窗
    closeBundlePhoneDialog() {
      this.isShowBundlePhoneDialog = false;
      this.initBundleForm();
    },
    // 搜索
    search() {
      // let isLogin = localStorage.getItem("isLogin");

      if (this.searchValue === "" || this.searchValue === null) {
        return;
      }
      this.$router.push({
        path: "/search",
        query: {
          searchValue: this.searchValue,
        },
      });
      // this.isShowSearchTip = false;
      this.closeSearch();
      this.$refs.searchInput.blur();
    },
    // 退出登录
    exitLogin() {
      this.closeDD();
      this.$router.push("/");
      clearCookies();
      this.isLogin = false;
      localStorage.removeItem("isLogin");
      localStorage.removeItem("phoneFirstLogin");
      localStorage.removeItem("pcFirstLogin");
      localStorage.removeItem("isJump");
      localStorage.removeItem("fragInfo");
      localStorage.removeItem("token");

      this.$store.commit("closeHomeNotice");
      this.clearUserInfo();
      this.$message({
        message: "账号已退出",
        iconClass: "mySuccessIcon",
        customClass: "mySuccess",
      });
    },
    changeMore() {
      this.isShowMore = !this.isShowMore;
      this.closeSearch();
    },
    closeMore() {
      this.isShowMore = false;
    },

    // -----跳转相关的方法-----
    // 切换路由
    changeNav(tab, event) {
      let isLogin = JSON.parse(localStorage.getItem("isLogin"));

      switch (tab.paneName) {
        // 首页
        case "home":
          this.$router.push("/");
          break;
        // 商城
        case "mail":
          this.$router.push("/mail");
          break;
        // 交易
        case "trade":
          this.$router.push("/");
          break;
        // 合成
        case "compose":
          if (isLogin) {
            this.$router.push("/syntheticList");
          } else {
            this.$message({
              message: "您还没有登录!",
              iconClass: "myErrorIcon",
              customClass: "myError",
            });
            setTimeout(() => {
              switch (this.$route.path) {
                case "/":
                  this.activeName = "home";
                  break;
                case "/mail/productItem":
                  this.activeName = "mail";
                  break;
                case "/aboutUs":
                  this.activeName = "about";
                  break;
                case "/noticeList":
                case "/noticeItem":
                  this.activeName = "notice";
                  break;
                case "/helpCenter":
                  this.activeName = "help";
                  break;
                case "/appDownload":
                  this.activeName = "app";
                  break;
              }
              this.isShowLogin = true;
            }, 300);
          }
          break;
        // 关于我们
        case "about":
          this.$router.push("/aboutUs");
          break;
        // APP
        case "app":
          this.$router.push("/appDownload");
          break;
        // 流转中心
        case "circulation":
          // this.$router.push("/helpCenter");
          window.open(
            "https://www.zgipmall.com/cr_mobile//#/register/0000004",
            "_blank"
          );
          setTimeout(() => {
            switch (this.$route.path) {
              case "/":
                this.activeName = "home";
                break;
              case "/mail/productItem":
                this.activeName = "mail";
                break;
              case "/aboutUs":
                this.activeName = "about";
                break;
              case "/helpCenter":
                this.activeName = "help";
                break;
              case "/noticeList":
              case "/noticeItem":
                this.activeName = "notice";
                break;
              case "/appDownload":
                this.activeName = "app";
                break;
              case "/syntheticList":
              case "/syntheticHistory":
              case "/syntheticAction":
                this.activeName = "compose";
                break;
              case "/mail/inviteCode":
                this.activeName = "invite";
                break;
            }
          }, 300);
          break;
        case "notice":
          this.$router.push("/noticeList");
          break;
        // 邀请好友
        case "invite":
          if (isLogin) {
            this.$router.push("/mail/inviteCode");
          } else {
            this.$message({
              message: "您还没有登录!",
              iconClass: "myErrorIcon",
              customClass: "myError",
            });
            setTimeout(() => {
              switch (this.$route.path) {
                case "/":
                  this.activeName = "home";
                  break;
                case "/mail/productItem":
                  this.activeName = "mail";
                  break;
                case "/aboutUs":
                  this.activeName = "about";
                  break;
                case "/noticeList":
                case "/noticeItem":
                  this.activeName = "notice";
                  break;
                case "/helpCenter":
                  this.activeName = "help";
                  break;
                case "/appDownload":
                  this.activeName = "app";
                  break;
              }
              this.isShowLogin = true;
            }, 300);
          }
          break;
        // 帮助中心
        case "help":
          // this.$router.push("/helpCenter");
          window.open(
            "https://www.yuque.com/docs/share/4b5d5f77-7dfd-4924-b3ac-b70f95d2760e",
            "_blank"
          );
          setTimeout(() => {
            switch (this.$route.path) {
              case "/":
                this.activeName = "home";
                break;
              case "/mail/productItem":
                this.activeName = "mail";
                break;
              case "/aboutUs":
                this.activeName = "about";
                break;
              case "/helpCenter":
                this.activeName = "help";
                break;
              case "/noticeList":
              case "/noticeItem":
                this.activeName = "notice";
                break;
              case "/appDownload":
                this.activeName = "app";
                break;
              case "/syntheticList":
              case "/syntheticHistory":
              case "/syntheticAction":
                this.activeName = "compose";
                break;
              case "/mail/inviteCode":
                this.activeName = "invite";
                break;
            }
          }, 300);
          break;
        default:
          break;
      }
    },
    // 返回按钮触发返回到上个界面
    goBack() {
      let isLogin = localStorage.getItem("isLogin");
      let backPath = localStorage.getItem("shopPath");
      // console.log(backPath);
      if (backPath) {
        this.$router.replace(backPath);
        localStorage.removeItem("shopPath");
      } else {
        if (this.$route.path === "/mail/productDetail") {
          this.$router.push("/mail/productItem");
        } else if (this.$route.path === "/personalModify") {
          this.$router.push("/personalCenter");
        } else {
          if (this.$route.path === "/login" && !isLogin) {
            this.$router.push("/");
          } else {
            setTimeout(() => {
              this.$router.go(-1);
            }, 100);
          }
        }
      }
    },
    // 跳转到个人中心
    gotoPersonalCenter() {
      this.getUserInfo();
      this.closeDD();
      setTimeout(() => {
        this.$router.push("/personalCenter");
      }, 100);
    },
    // 跳转到搜索界面
    gotoSearch() {
      this.$router.push("/search");
    },
    // 跳转到实名认证界面
    gotoAuth() {
      if (this.userInfo.is_auth === 0) {
        this.$router.push("/auth");
      } else {
        this.$router.push("/auth_ok");
      }
      this.closeDD();
    },
    // 打开隐私政策页面
    gotoPrivacy() {
      window.open("/#/privacy", "_blank");
    },
    // 打开用户协议页面
    gotoAgreement() {
      window.open("/#/userAgreement", "_blank");
    },
    // 跳转到转赠记录界面
    gotoTransferHistory() {
      this.$router.push("/transferHistory");
    },
    // 跳转到合成历史
    gotoSyntheticHistory() {
      this.$router.push("/syntheticHistory");
    },
    // 跳转到帮助中心
    gotoHelp() {
      window.open(
        "https://www.yuque.com/docs/share/4b5d5f77-7dfd-4924-b3ac-b70f95d2760e",
        "_blank"
      );
      this.closeMore();
    },
    // 跳转到关于我们
    gotoAbout() {
      this.$router.push("/aboutUs");
      this.closeMore();
    },
    // 跳转到流转帮助
    gotoHelpPage() {
      this.$message({
        message: "请在APP中打开",
        iconClass: "myWarningIcon",
        customClass: "myWarning",
      });
      this.closeMore();
      setTimeout(() => {
        this.$router.push("/appDownload");
      }, 1000);
    },
  },
};
</script>

<style lang="less" scoped>
#homeBar {
  width: 100%;
  z-index: 999;

  .wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 1200px;
    height: 100%;
    margin: 0 auto;
  }

  .mBar {
    display: none;
  }

  .mBrace {
    display: none;
  }

  .mTopDiv {
    display: none;
  }

  .bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: #1e2020;
    z-index: 999;

    .bar_nav {
      height: 100%;
      display: flex;
      align-items: center;

      .bar_logo {
        .logoImg {
          width: 62px;
          height: 40px;
        }
      }

      .bar_nav_box {
        position: relative;
        height: 100%;
        margin-left: 60px;

        /deep/.noticeDot {
          .el-badge__content.is-fixed.is-dot {
            top: 10px;
            right: 2px;
            border: none;
            background-color: #f34c44;
          }
        }

        .hot {
          position: absolute;
          top: 13px;
          right: -28px;
          width: 24px;
          height: 15px;
          z-index: 9999;
        }

        /deep/.el-tabs__header {
          padding: 0;
          margin: 0;
        }

        /deep/.el-tabs__content {
          display: none;
        }

        // 字体样式修改
        /deep/.el-tabs__item {
          display: flex;
          align-items: center;
          height: 60px;
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #ffffff;
        }

        // 长下划线样式
        /deep/.el-tabs__nav-wrap::after {
          opacity: 0;
          height: 4px;
        }

        // 当前选中的字体
        /deep/.is-active {
          color: #00ffb0;
        }

        // 当前选中下滑蓝边
        /deep/.el-tabs__active-bar {
          height: 4px;
          background: #00ffb0;
        }
      }

      .bar_more {
        position: relative;
        margin-left: 41px;

        .more_click {
          display: flex;
          align-items: center;
          cursor: pointer;

          span {
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #ffffff;
          }

          i {
            font-size: 14px;
            font-weight: 500;
            color: white;
            opacity: 0.5;
          }
        }

        .more_dd {
          position: absolute;
          top: 35px;
          left: -53px;
          min-width: 138px;
          background: #1e2020;
          box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.2);
          border-radius: 4px;

          ul,
          li {
            width: 100%;
            list-style: none;
            margin: 0;
            padding: 0;
          }

          ul {
            padding: 10px 0;
          }

          li {
            display: flex;
            align-items: center;
            justify-content: center;
            height: 36px;
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #ffffff;
            line-height: 14px;
            cursor: pointer;
            opacity: 0.5;
            transition: all 0.2s;
          }

          li:hover {
            background: rgba(255, 255, 255, 0.03);
            opacity: 1;
          }
        }

        .fade-enter-active,
        .fade-leave-active {
          transition: all 0.3s;
        }

        .fade-enter,
        .fade-leave-active {
          opacity: 0;
        }
      }
    }

    .bar_search {
      position: relative;
      display: flex;
      align-items: center;

      .start {
        position: absolute;
        left: 15px;
        width: 14px;
        height: 14px;
      }

      .end {
        position: absolute;
        right: 50%;
        width: 16px;
        height: 16px;
        z-index: 2;
        transform: translateX(15px);
        cursor: pointer;
      }

      .end_close {
        position: absolute;
        right: 50%;
        width: 16px;
        height: 16px;
        cursor: pointer;
        transform: translateX(75px);
        z-index: 2;
      }

      .search_input {
        width: 220px;
        height: 32px;
        background: #343636;
        border-radius: 16px;
        font-size: 14px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #ffffff;
        line-height: 14px;
        border: none;
        padding-left: 39px;
        padding-right: 10px;
        transition: all 0.5s ease;
      }

      .search_input_search {
        width: 560px;
        height: 40px;
        border-radius: none;
        font-size: 16px;
        font-weight: 400;
        line-height: 16px;
        background: #343636;
        font-family: PingFangSC-Regular, PingFang SC;
        color: #ffffff;
        border: none;
        padding-left: 20px;
        transform: translateX(-200px);
        transition: all 0.5s ease;
      }

      input::-webkit-input-placeholder {
        /* WebKit browsers 适配谷歌 */
        color: rgba(255, 255, 255, 0.5) !important;
      }

      input:-moz-placeholder {
        /* Mozilla Firefox 4 to 18 适配火狐 */
        color: rgba(255, 255, 255, 0.5) !important;
      }

      input::-moz-placeholder {
        /* Mozilla Firefox 19+ 适配火狐 */
        color: rgba(255, 255, 255, 0.5) !important;
      }

      input:-ms-input-placeholder {
        /* Internet Explorer 10+  适配ie*/
        color: rgba(255, 255, 255, 0.5) !important;
      }

      .bar_login {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 100px;
        height: 32px;
        background: none;
        border: none;
        border-radius: 0 !important;
        background-image: url("../assets/images/pc_black/home/login_color.png");
        background-position: center center;
        background-size: 100% 100%;
        font-size: 14px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #1e2020;
        line-height: 14px;
        margin-left: 20px;
      }

      .bar_userInfo {
        position: relative;
        display: flex;
        align-items: center;
        margin-left: 41px;

        .bar_click {
          display: flex;
          align-items: center;
          cursor: pointer;

          .bar_avatar {
            position: unset;
            width: 30px;
            height: 30px;
            border-radius: 50%;
          }

          i {
            font-size: 14px;
            font-weight: 500;
            color: white;
            opacity: 0.5;
          }
        }

        .bar_dd {
          position: absolute;
          top: 35px;
          left: -53px;
          min-width: 138px;
          background: #1e2020;
          box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.2);
          border-radius: 4px;

          ul,
          li {
            width: 100%;
            list-style: none;
            margin: 0;
            padding: 0;
          }

          ul {
            padding: 10px 0;
          }

          li {
            display: flex;
            align-items: center;
            height: 36px;
            padding-left: 15px;
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #ffffff;
            line-height: 14px;
            cursor: pointer;
            opacity: 0.5;
            transition: all 0.2s;
          }

          li:hover {
            background: rgba(255, 255, 255, 0.03);
            opacity: 1;
          }

          .dd_auth {
            opacity: 1;

            span {
              word-break: keep-all;
            }

            span:nth-child(1) {
              opacity: 0.5;
            }

            span:nth-child(2) {
              font-size: 12px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #00ffb0;
              line-height: 12px;
              margin-left: 16px;
              opacity: 1;
            }
          }

          .dd_auth:hover {
            span:nth-child(1) {
              opacity: 1;
            }
          }
        }

        .fade-enter-active,
        .fade-leave-active {
          transition: all 0.3s;
        }

        .fade-enter,
        .fade-leave-active {
          opacity: 0;
        }

        // 双击不选中
        -moz-user-select: none;
        -webkit-user-select: none;
        -ms-user-select: none;
        -khtml-user-select: none;
        user-select: none;
      }

      .bar_search_content {
        position: absolute;
        top: 40px;
        left: -200px;
        width: 560px;
        height: 300px;
        background: #1e2020;
        box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.2);
      }

      // 搜索框内容区域过度
      .searchfade-enter-active,
      .searchfade-leave-active {
        transition: all 0.5s ease;
      }

      .searchfade-enter,
      .searchfade-leave-active {
        opacity: 0;
      }

      // 双击不选中
      -moz-user-select: none;
      -webkit-user-select: none;
      -ms-user-select: none;
      -khtml-user-select: none;
      user-select: none;

      /* 设置滚动条的样式 */
      ::-webkit-scrollbar {
        width: 6px;
        border-radius: 3px;
        display: none;
      }

      /* 滚动槽 */
      ::-webkit-scrollbar-track {
        border-radius: 10px;
      }

      /* 滚动条滑块 */
      ::-webkit-scrollbar-thumb {
        border-radius: 10px;
        background: #a0a0a0;
        height: 105px;
      }

      // - 搜索提示
      .search_tip {
        width: 100%;
        height: 100%;
        padding: 0 20px;
        overflow: auto;

        ul,
        li {
          width: 100%;
        }

        ul {
          height: 100%;
        }

        li {
          display: flex;
          align-items: center;
          height: 50px;
          box-shadow: 0px 1px 0px 0px #333333;
          font-size: 15px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #ffffff;
          line-height: 15px;
          word-break: keep-all;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          cursor: pointer;
        }
      }

      // - 搜索历史立即
      .search_history {
        width: 100%;
        height: 100%;
        padding: 0 20px;
        overflow: hidden;

        .history_title {
          display: flex;
          justify-content: space-between;
          align-items: center;
          width: 100%;
          height: 24px;
          margin-top: 20px;

          .title_font {
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #999999;
            line-height: 12px;
          }

          .title_img {
            width: 12px;
            height: 12px;
            cursor: pointer;
          }
        }

        .history_content {
          display: flex;
          flex-wrap: wrap;
          align-content: flex-start;
          width: 100%;
          height: 215px;
          margin-top: 15px;
          overflow: auto;

          .content_item {
            display: flex;
            justify-content: center;
            align-items: center;
            height: 26px;
            background: #343636;
            border-radius: 20px;
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #999999;
            line-height: 12px;
            padding: 0 10px;
            margin: 0 10px 10px 0;
            cursor: pointer;
          }
        }
      }
    }
  }

  .pcBrace {
    display: block;
    width: 100%;
    height: 60px;
  }

  // 登录注册弹窗
  .loginDialog {
    /deep/.el-dialog {
      max-width: 460px;
      height: 640px;
      background: #1e2020;
      border-radius: 10px;

      .el-dialog__header {
        display: none;
      }

      .el-dialog__body {
        margin: 0;
        padding: 0;

        .dialog_title {
          display: flex;
          justify-content: flex-end;
          width: 100%;
          padding: 30px 30px 0 0;

          img {
            width: 16px;
            height: 16px;
            cursor: pointer;
          }
        }

        .dialog_center {
          position: relative;
          width: 100%;
          padding: 0 50px;
          padding-top: 34px;

          .form_title {
            display: flex;
            flex-direction: column;

            span:nth-child(1) {
              font-family: PingFangSC-Medium, PingFang SC;
              font-size: 24px;
              font-weight: 500;
              color: #ffffff;
              line-height: 24px;
            }

            span:nth-child(2) {
              font-size: 18px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #999999;
              line-height: 18px;
              margin-top: 40px;
            }
          }

          .form_content {
            position: relative;
            display: flex;
            flex-direction: column;
            padding-top: 30px;
            height: 295px;

            input {
              height: 50px;
              background: #292b2b;
              border-radius: 4px;
              border: none;
              padding-left: 20px;
              padding-right: 110px;
              font-size: 16px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #ffffff;
              line-height: 16px;
            }

            input:nth-child(2) {
              margin-top: 20px;
            }

            input::-webkit-input-placeholder {
              /* WebKit browsers 适配谷歌 */
              color: rgba(255, 255, 255, 0.5) !important;
            }

            input:-moz-placeholder {
              /* Mozilla Firefox 4 to 18 适配火狐 */
              color: rgba(255, 255, 255, 0.5) !important;
            }

            input::-moz-placeholder {
              /* Mozilla Firefox 19+ 适配火狐 */
              color: rgba(255, 255, 255, 0.5) !important;
            }

            input:-ms-input-placeholder {
              /* Internet Explorer 10+  适配ie*/
              color: rgba(255, 255, 255, 0.5) !important;
            }

            .getCodeBtn {
              position: absolute;
              right: 20px;
              top: 116px;
              background: none;
              border: none;
              font-size: 16px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #00ffb0;
              line-height: 16px;
              cursor: pointer;
            }

            .opacityHalf {
              color: #999999;
            }

            .form_captch {
              background-color: #1e2020;
              width: 100%;
              height: 50px;
              margin-top: 20px;
            }

            .form_btn {
              width: 100%;
              margin-top: 20px;

              button {
                height: 50px;
                width: 100%;
                font-size: 16px;
                font-family: PingFangSC-Semibold, PingFang SC;
                font-weight: 600;
                color: #1e2020;
                line-height: 16px;
                border: none;
                background-size: 100% 100% !important;
                cursor: pointer;
              }

              .btn_color {
                background: url("../assets/images/pc_black/auth/btn_color.png")
                  no-repeat center center;
              }

              .btn_grey {
                background: url("../assets/images/pc_black/auth/btn_grey.png")
                  no-repeat center center;
              }
            }
          }

          .form_agree {
            padding-top: 10px;
            // padding-top: 60px;

            .login_agree {
              img {
                width: 14px;
                height: 14px;
                cursor: pointer;
              }

              span {
                font-size: 14px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #ffffff;
                line-height: 14px;
                margin-left: 10px;
                cursor: pointer;
              }
            }

            .privacy_agree {
              display: flex;

              img {
                width: 14px;
                height: 14px;
                transform: translateY(5px);
                cursor: pointer;
              }

              div {
                // width: 336px;
                font-size: 14px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #999999;
                line-height: 22px;
                margin-left: 10px;
              }

              .privacySpan {
                color: #00ffb0;
                cursor: pointer;
              }
            }
          }

          .other_login {
            width: 100%;

            .wx_line {
              display: flex;
              justify-content: space-between;
              align-items: center;
              width: 100%;
              padding-top: 30px;

              i {
                width: 100%;
                height: 1px;
                background-color: #333333;
              }

              span {
                font-size: 14px;
                font-family: PingFangSC-Regular, PingFang SC;
                font-weight: 400;
                color: #999999;
                line-height: 14px;
                word-break: keep-all;
                margin: 0 15px;
              }
            }

            .wx_img {
              display: flex;
              justify-content: center;
              align-items: center;
              width: 100%;
              padding-top: 20px;

              img {
                width: 40px;
                height: 40px;
                cursor: pointer;
              }
            }
          }
        }

        // 双击不选中
        -moz-user-select: none;
        -webkit-user-select: none;
        -ms-user-select: none;
        -khtml-user-select: none;
        user-select: none;
      }
    }
  }

  // 二维码弹窗
  .wxDialog {
    .ewm {
      width: 100%;
      margin: 0 auto;
    }
  }

  // 绑定手机号弹窗
  .bundleDialog {
    /deep/.el-dialog {
      max-width: 460px;
      height: 480px;
      background: #1e2020;
      border-radius: 10px;

      .el-dialog__header {
        display: none;
      }

      .el-dialog__body {
        margin: 0;
        padding: 0;

        .dialog_title {
          display: flex;
          justify-content: flex-end;
          width: 100%;
          padding: 30px 30px 0 0;

          img {
            width: 16px;
            height: 16px;
            cursor: pointer;
          }
        }

        .dialog_center {
          width: 100%;
          padding: 0 50px;
          padding-top: 34px;

          .form_title {
            display: flex;
            flex-direction: column;

            span:nth-child(1) {
              font-family: PingFangSC-Medium, PingFang SC;
              font-size: 24px;
              font-weight: 500;
              color: #ffffff;
              line-height: 24px;
            }

            span:nth-child(2) {
              font-size: 18px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #999999;
              line-height: 18px;
              margin-top: 40px;
            }
          }

          .form_content {
            position: relative;
            display: flex;
            flex-direction: column;
            padding-top: 30px;

            input {
              height: 50px;
              background: #292b2b;
              border-radius: 4px;
              border: none;
              padding-left: 20px;
              padding-right: 110px;
              font-size: 16px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #ffffff;
              line-height: 16px;
            }

            input:nth-child(2) {
              margin-top: 20px;
            }

            input::-webkit-input-placeholder {
              /* WebKit browsers 适配谷歌 */
              color: rgba(255, 255, 255, 0.5) !important;
            }

            input:-moz-placeholder {
              /* Mozilla Firefox 4 to 18 适配火狐 */
              color: rgba(255, 255, 255, 0.5) !important;
            }

            input::-moz-placeholder {
              /* Mozilla Firefox 19+ 适配火狐 */
              color: rgba(255, 255, 255, 0.5) !important;
            }

            input:-ms-input-placeholder {
              /* Internet Explorer 10+  适配ie*/
              color: rgba(255, 255, 255, 0.5) !important;
            }

            .getCodeBtn {
              position: absolute;
              right: 20px;
              // bottom: 17px;
              top: 115px;
              background: none;
              border: none;
              font-size: 16px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #00ffb0;
              line-height: 16px;
              cursor: pointer;
            }

            .opacityHalf {
              opacity: 0.5;
            }

            .form_captch {
              background-color: #1e2020;
              width: 100%;
              height: 50px;
              margin-top: 20px;
            }

            .form_btn {
              width: 100%;
              margin-top: 40px;

              button {
                height: 50px;
                width: 100%;
                font-size: 16px;
                font-family: PingFangSC-Semibold, PingFang SC;
                font-weight: 600;
                color: #1e2020;
                line-height: 16px;
                border: none;
                background-size: 100% 100% !important;
                cursor: pointer;
              }

              .btn_color {
                background: url("../assets/images/pc_black/auth/btn_color.png")
                  no-repeat center center;
              }

              .btn_grey {
                background: url("../assets/images/pc_black/auth/btn_grey.png")
                  no-repeat center center;
              }
            }

            .form_btn_margin {
              margin-top: 20px;
            }
          }
        }

        // 双击不选中
        -moz-user-select: none;
        -webkit-user-select: none;
        -ms-user-select: none;
        -khtml-user-select: none;
        user-select: none;
      }
    }
  }

  /deep/.el-dialog__wrapper {
    background: rgba(0, 0, 0, 0.9);
  }

  // 历史记录弹窗
  .historyDialog {
    /deep/.el-dialog {
      max-width: 480px;
      height: 192px;
      background: #1e2020;
      border-radius: 4px;
      box-shadow: 0px 12px 48px 16px rgba(0, 0, 0, 0.03),
        0px 9px 28px 0px rgba(0, 0, 0, 0.05),
        0px 6px 16px -8px rgba(0, 0, 0, 0.08);

      .el-dialog__header {
        display: none;
      }

      .el-dialog__body {
        margin: 0;
        padding: 0;

        .dialog_title {
          display: flex;
          justify-content: space-between;
          width: 100%;
          padding: 20px 20px 0 20px;

          span {
            font-size: 16px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: rgba(255, 255, 255, 0.85);
            line-height: 16px;
          }

          img {
            width: 16px;
            height: 16px;
            cursor: pointer;
          }
        }

        .dialog_center {
          width: 100%;
          padding: 23px 0 0 20px;
          font-size: 14px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #999999;
          line-height: 22px;
        }

        .dialog_bottom {
          display: flex;
          justify-content: flex-end;
          width: 100%;
          position: absolute;
          bottom: 0;
          left: 0;
          padding: 0 15px 10px 0;

          .el-button {
            display: flex;
            justify-content: center;
            align-items: center;
            margin: 0;
            padding: 0;
            margin-left: 10px;
            background: none;
            border: none;
            width: 68px;
            height: 32px;
            border-radius: 3px;
            font-size: 14px;
            font-family: PingFangSC-Regular, PingFang SC;
            line-height: 14px;
          }

          .el-button:nth-child(1) {
            border: 1px solid #666666;

            font-weight: 400;
            color: #999999;
          }

          .el-button:nth-child(2) {
            background: #00ffb0;
            font-weight: 500;
            color: #1e2020;
          }
        }

        // 双击不选中
        -moz-user-select: none;
        -webkit-user-select: none;
        -ms-user-select: none;
        -khtml-user-select: none;
        user-select: none;
      }
    }
  }

  // transition
  .fade1-enter-active,
  .fade1-leave-active {
    transition: opacity 0.5s;
  }

  .fade1-enter,
  .fade1-leave-to

  /* .fade-leave-active below version 2.1.8 */
 {
    opacity: 0;
  }

  .fade2-enter-active {
    transition: opacity 0.5s;
  }

  .fade2-enter,
  .fade2-leave-active {
    opacity: 0;
  }
}

@media screen and (max-width: 768px) {
  #homeBar {
    .mBar {
      // position: fixed;
      position: absolute;
      top: 0;
      left: 0;
      display: flex;
      align-items: center;
      width: 100%;
      height: 90px;
      // background: #f4f4f4;
      background: #1e2020;
      z-index: 200099;

      .mBar_left {
        position: relative;
        width: 22px;
        height: 22px;
        left: 30px;
      }

      .mBar_left::before,
      .mBar_left::after {
        position: absolute;
        content: " ";
        background-color: #ffffff;
        left: 10px;
        width: 2px;
        height: 27px;
      }

      .mBar_left::before {
        transform: rotate(45deg);
      }

      .mBar_left::after {
        transform: rotate(-45deg);
      }

      .mBar_left2 {
        position: relative;
        width: 22px;
        height: 22px;
        left: 30px;
        border-top: 2px solid #ffffff;
        border-right: 2px solid #ffffff;
        transform: rotate(-135deg);
      }

      .mBar_center {
        position: absolute;
        left: 50%;
        transform: translateX(-50%);
        // font-size: 24px;
        font-size: 30px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #ffffff;
      }

      .mBar_right {
        position: absolute;
        right: 30px;
        font-size: 28px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #00ffb0;
      }
    }

    .mBrace {
      display: block;
      height: 90px;
      width: 100%;
    }

    .bar,
    .pcBrace {
      display: none;
    }
  }
}
</style>
